package com.vcg.neo4j.dubbo.service;

/**
 * Created by wuyu on 2016/8/7.
 */
public class DynamicExportClassLoader extends ClassLoader {

    private  static ThreadLocal<byte[]> currentClass = new ThreadLocal<>();

    @Override
    protected Class<?> findClass(final String name) throws ClassNotFoundException {
        byte[] classBytes = currentClass.get();
        if (classBytes != null) {
            currentClass.set(null);
            return defineClass(name, classBytes, 0, classBytes.length);
        }
        return super.findClass(name);
    }

    public void setCurrentClass(byte[] bytes){
        currentClass.set(bytes);
    }
}
